<%--
  Created by IntelliJ IDEA.
  User: dell
  Date: 2023-06-27
  Time: 11:30
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>用户登录</title>
</head>
<body>
<div style="text-alian: center">
    <form action="login.jsp" method="post" id="loginForm">
        姓名：<input type="text" name="uname" ><br>
        密码：<input type="password" name="upwd" ><br>
        <span id="msg" style="font-size: 12px;color:red"></span><br>
        <button type="button" id="loginBtn">登录</button>
        <button type="button">注册</button>
    </form>
</div>
</body>
<%--引入jq文件--%>
<script type="text/javascript" src="js/jquery-3.4.1.js"></script>
<script type="text/javascript">
    $("#loginBtn").click(function (){
        //获取用户姓名和密码
        var uname=$("#uname").val();
        var upwd=$("#upwd").val();

        //判断姓名是否为空
        if(isEmpty(uname)){
            $("#msg").html("用户密码不可为空！！！");
            return;
        }
        //判断密码是否为空
        if(isEmpty(upwd)){
            $("#msg").html("用户密码不可为空！！！");
            return;
        }
        //如果都不为空,手动提交表单
        $("#loginForm").submit();
    });

    //判断用户姓名和密码是否为空
    function isEmpty(str){
        if(str==null || str.trim()==""){
            return true;
        }
        return false;
    }
</script>
</html>
